<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>作业样式绑定类升级版</title>
    <script src="../../js/vue3.js"></script>
    <style>
        #app{
            margin: 5rem auto;
            width: 50%;
            text-align: center;
        }
        p{
            font-size: 10rem;
            font-weight: bold;
        }
    </style>
</head>

<body>
    <div id="app" >
        <p v-bind:style="{color:changeColor}">我会变色</p>
        <button v-on:click="colors" v-bind:style="{backgroundColor:changeColor}">彳亍</button>
    </div>
    <script>
        const v_app = Vue.createApp({
            data(){
                return{
                    changeColor:"rgb(100,200,300)"
                }
            },
            methods:{
                colors(){
                    let r = Math.floor(Math.random()*255)
                    let g = Math.floor(Math.random()*255)
                    let b = Math.floor(Math.random()*255)
                    this.changeColor = "rgb("+r+","+g+","+b+")"
                }
            }
        });
        v_app.mount("#app");
    </script>
</body>

</html>